home *** CD-ROM | disk | FTP | other *** search
/ One Click 14 / OneClick14.iso / Ferramentas / Convert XLS to Pdf / xls2pdf_setup.exe / {app} / lib / gs_devcs.ps < prev    next >
Encoding:
Text File  |  2002-08-22  |  5.1 KB  |  208 lines

  1. %    Copyright (C) 2002 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_devcs.ps,v 1.1 2002/08/22 07:12:28 henrys Exp $
  14. % Device-specific color space method dictionaries.
  15.  
  16. %
  17. % This file implements the method dictionaries for the Device-specific
  18. % color spaces. See gs_cspace.ps for information.
  19. %
  20. % Note that, because these color spaces are parameter-less, no color
  21. % space validation is required: if we can get to the color space methods,
  22. % we know the color space is legitimate.
  23. %
  24. % The colorspace substitution routines for these color spaces
  25. % (cs_substitute) will fail in a Level 1 system, but this is not a
  26. % problem as .getuseciecolor will always return false for such systems.
  27. %
  28. .currentglobal true .setglobal
  29. .cspace_util begin
  30.  
  31. %
  32. %   <r>  <g>  <b>   rgb_2_gray   <gray>
  33. %
  34. % Convert RGB colors to gray. This includes a special check for
  35. % r == g == b, and avoids roundoff error if this is the case.
  36. %
  37. /rgb_2_gray
  38.   {
  39.     3 copy 1 index eq 3 1 roll eq and
  40.       { pop pop }
  41.       { .11 mul exch .59 mul add exch .3 mul add }
  42.     ifelse
  43.   }
  44. bind def
  45.  
  46.  
  47. colorspacedict
  48.  
  49. dup
  50. /DeviceGray
  51.   mark
  52.     /cs_potential_indexed_base true
  53.     /cs_potential_pattern_base true
  54.     /cs_potential_alternate true
  55.     /cs_potential_icc_alternate true
  56.     /cs_get_ncomps //ncomps_1
  57.     /cs_get_range  //get_range_1
  58.     /cs_get_default_color { pop 0 } bind
  59.     /cs_get_currentgray //pop_1
  60.     /cs_get_currentrgb { pop dup dup } bind
  61.     /cs_get_currentcmyk { pop 1 exch sub 0 0 0 4 -1 roll } bind
  62.     /cs_validate {}
  63.  
  64.     /cs_substitute
  65.       {
  66.         .getuseciecolor
  67.           { /DefaultGray /ColorSpace findresource }
  68.           { dup }
  69.         ifelse
  70.       }
  71.     bind
  72.  
  73.     /cs_prepare {}
  74.     /cs_install { pop 0 .setdevcspace } bind
  75.     /cs_prepare_color //validate_1
  76.     /cs_complete_setcolor //pop_1
  77.   .dicttomark
  78. put
  79.  
  80.  
  81. /DeviceRGB
  82.   mark
  83.     /cs_potential_indexed_base true
  84.     /cs_potential_pattern_base true
  85.     /cs_potential_alternate true
  86.     /cs_potential_icc_alternate true
  87.     /cs_get_ncomps //ncomps_3
  88.     /cs_get_range  //get_range_3
  89.     /cs_get_default_color { pop 0 0 0 } bind
  90.     /cs_get_currentgray { pop //rgb_2_gray exec } bind
  91.     /cs_get_currentrgb //pop_1
  92.  
  93.     % to convert to cmyk use blackgeneration and undercolorremoval
  94.     /cs_get_currentcmyk
  95.       {
  96.         pop
  97.  
  98.         % convert to subtractive (CMY) color space
  99.         3
  100.           { 1 exch sub 3 1 roll }
  101.         repeat
  102.  
  103.         % find the minimum (initial k component)
  104.         3 copy
  105.         2
  106.           {
  107.             2 copy gt
  108.               { exch }
  109.             if
  110.             pop
  111.           }
  112.         repeat
  113.  
  114.         % apply undercolorremoval
  115.         dup 5 1 roll currentundercolorremoval exec 4 1 roll
  116.         3
  117.           { 3 index sub //bound_0_1 exec 3 1 roll }
  118.         repeat
  119.  
  120.         % apply blackgeneration
  121.         5 3 roll pop currentblackgeneration exec //bound_0_1 exec
  122.       }
  123.     bind
  124.  
  125.     /cs_validate {}
  126.  
  127.     /cs_substitute
  128.       {
  129.         .getuseciecolor
  130.           { /DefaultRGB /ColorSpace findresource }
  131.           { dup }
  132.         ifelse
  133.       }
  134.     bind
  135.  
  136.     /cs_prepare {}
  137.     /cs_install { pop 1 .setdevcspace } bind
  138.     /cs_prepare_color //validate_3
  139.     /cs_complete_setcolor //pop_1
  140.   .dicttomark
  141. put
  142.  
  143. end     % .cspace_util
  144. .setglobal
  145.  
  146.  
  147. % Only create the DeviceCMYK color space if setcolorscreen is present
  148. /setcolorscreen where
  149.   { pop }
  150.   { currentfile closefile }
  151. ifelse
  152.  
  153.  
  154. .currentglobal true .setglobal
  155. .cspace_util begin
  156.  
  157. colorspacedict
  158. /DeviceCMYK
  159.   mark
  160.     /cs_potential_indexed_base true
  161.     /cs_potential_pattern_base true
  162.     /cs_potential_alternate true
  163.     /cs_potential_icc_alternate true
  164.     /cs_get_ncomps //ncomps_4
  165.     /cs_get_range  //get_range_4
  166.     /cs_get_default_color { pop 0 0 0 1 } bind
  167.  
  168.     /cs_get_currentgray
  169.       { pop 4 1 roll //rgb_2_gray exec add 1 exch sub //bound_0_1 exec }
  170.     bind
  171.  
  172.     /cs_get_currentrgb 
  173.       {
  174.         pop
  175.         4 1 roll 3
  176.           { 3 index add  1 exch sub //bound_0_1 exec 3 1 roll }
  177.         repeat
  178.         4 -1 roll pop
  179.       }
  180.     bind
  181.  
  182.     /cs_get_currentcmyk //pop_1
  183.  
  184.     /cs_validate {}
  185.  
  186.     /cs_substitute
  187.       {
  188.         .getuseciecolor
  189.           { /DefaultCMYK /ColorSpace findresource }
  190.           { dup }
  191.         ifelse
  192.       }
  193.     bind
  194.  
  195.     /cs_prepare {}
  196.     /cs_install { pop 2 .setdevcspace } bind
  197.     /cs_prepare_color //validate_4
  198.     /cs_complete_setcolor //pop_1
  199.   .dicttomark
  200. put
  201.  
  202. end     % .cspace_util
  203. .setglobal
  204.  
  205.